/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package BeanManager;

import java.util.List;
import mapper.FavorisMapper;
import mapper.MessageMapper;
import org.apache.ibatis.session.SqlSession;
import packageEntities.Favoris;
import service.ConnexionBd;
import static service.ConnexionBd.session;

/**
 *
 * @author nmeli
 */
public class FavorisManager {
   public static  List<Favoris> affiche() {
      SqlSession unesession= ConnexionBd.getConnexion();
            FavorisMapper message = session.getMapper(FavorisMapper.class);           
            List<Favoris> mesFavoris = message.getAll();
            ConnexionBd.closeConnexion();
            return mesFavoris;
} 
    public static boolean ajout(Favoris fav) {
        int nbMod = 0;
        SqlSession session = ConnexionBd.getConnexion();
        FavorisMapper favoris = session.getMapper(FavorisMapper.class);
        nbMod = favoris.AjoutFavoris(fav);

        session.commit();

        ConnexionBd.closeConnexion();
        return (nbMod > 0 ? true : false);
   
      }
     public static  List<Favoris> afficheParMembre(int id) {
      SqlSession unesession= ConnexionBd.getConnexion();
            FavorisMapper favoris = session.getMapper(FavorisMapper.class);           
            List<Favoris> mesFavoris = favoris.getMembreFavorise(id);
            ConnexionBd.closeConnexion();
            return mesFavoris;
}
}
